﻿@{
    Layout = "";
}

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
    <title>客户详细</title>
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.1.3/css/bootstrap.min.css">
    <!-- customer-details CSS -->
    <link rel="stylesheet" href="~/GoTRI/css/mobiscroll.custom.min.css">
    <link rel="stylesheet" href="~/GoTRI/css/customer-details.css?v=3">
    <link rel="stylesheet" href="~/GoTRI/css/tel-note.css">
    <!-- jQuery first, then Popper.js, then Bootstrap JS -->
    <script src="~/GoTRI/js/jquery-3.2.1.min.js"></script>
    <script src="~/GoTRI/js/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.1.3/js/bootstrap.min.js"></script>
    <script src="~/admui-13945148017-1592211513218/public/js/tsk/sweetalert.min.js"></script>
    <script>
        $(document).ready(function () {
            $("#nb").removeAttr("hidden");
            var KeHuId = getQuery("KeHuId");
            PanDuanShiFouQueRenGuo(KeHuId);
            BindKeHu(KeHuId);
            BindGenJinJiLu(KeHuId);
        });

        function BindKeHu(KeHuId) {
            $.ajax({
                type: "POST",
                url: "../PhoneKeHu/BindKeHuJiBenXinXi",
                cache: false,  //禁用缓存
                data: { "KeHuId": "" + KeHuId + "" },  //传入组装的参数
                dataType: "json",
                success: function (result) {
                    for (var i = 0; i < result.length; i++) {
                        $("#lbl_KeHuXingMing").text(result[0].KeHuXingMing);
                        $("#txt_KeHuXingMing").val(result[0].KeHuXingMing);
                        $("#lbl_ZhuangTai").text(result[0].ZhuangTai);
                        $("#lbl_TuiJianShiJian").text(result[0].BeiZhu1);
                        $("#txt_ShouJiHaoMa").val(ShouJi(result[0].ShouJiHaoMa));
                        $("#txt_BeiZhu").val(result[0].KeHuBeiZhu);
                        //$("#lbl_YiQianYue").text(result[0].YiQianYue);
                        //$("#lbl_YiTuiFang").text(result[0].YiTuiFang);
                        //$("#lbl_YiShiXiao").text(result[0].YiShiXiao);

                        if (result[0].XingBie == "男") {
                            $("#img_TouXiangNan").show();
                            $("#img_TouXiangNv").hide();
                        }
                        else {
                            $("#img_TouXiangNan").hide();
                            $("#img_TouXiangNv").show();
                        }

                    }
                }
            });
        }

        function BindGenJinJiLu(KeHuId) {
            $.ajax({
                type: "POST",
                url: "../PhoneKeHu/BindXiaoShouJiLu",
                cache: false,  //禁用缓存
                data: { "KeHuId": "" + KeHuId + "" },  //传入组装的参数
                dataType: "json",
                success: function (result) {
                    console.log(result);
                    //var left = "";
                    var daofang = false;
                    var yigoumai = false;
                    var right = "";
                    for (var i = 0; i < result.length; i++) {

                        if (result[i].XiaoShouDongZuo == "已认购" && yigoumai == false) {
                            yigoumai = true;
                        }
                        if (result[i].XiaoShouDongZuo == "到访" && daofang == false) {
                            daofang = true;
                        }


                        if (i == 0) {
                            $("#lbl_ShangCiGenJin").text(result[i].CaoZuoShiJian);
                        }

                        //left += "<div><div class=\"circle1 actived\"><div></div></div></div><div class=\"line1\"></div>";

                        var zhiyeguwen = "";
                        if (result[i].XiaoShouDongZuo == "到访") {
                            zhiyeguwen += "" +
                                "<div class=\"item-foot\" style=\"margin-bottom: 5px;\">" +
                                "<span>置业顾问</span>-" +
                                "<span>" + result[i].ZhiYeGuWen + "</span>" +
                                "(<span>" + result[i].ZhiYeGuWenDianHua + "</span>)" +
                                "</div>";
                        }
                        if (result[i].XiaoShouDongZuo == "确认到访") {
                            zhiyeguwen += "" +
                                "<div class=\"item-foot\" style=\"margin-bottom: 5px;\">" +
                                "<span>确认状态</span>-是否到访：" +
                                "<span>" + result[i].QueRenZhuangTai + "</span>" +
                                "</div>";
                        }

                        right += "<div class=\"right-item\">" +
                            "<div class=\"item-tit\">" +
                            "<div class=\"tit-left\"><div><div class=\"circle actived\"><div></div></div></div><span>" + result[i].XiaoShouDongZuo + "</span></div><span>" + result[i].CaoZuoShiJian + "</span>" +


                            //"<span>" + result[i].XiaoShouDongZuo + "</span>" +
                            //"<span>" + result[i].CaoZuoShiJian+"</span>" +
                            "</div>" +
                            "<div class=\"tit-body\">" +
                            "<div class=\"item-content\">" + result[i].MiaoShu + "</div>" + zhiyeguwen +
                            "<div class=\"item-foot\">" +
                            "<span>操作人</span>-" +
                            "<span>" + result[i].CaoZuoRen + "</span>" +
                            "(<span>" + result[i].CaoZuoRenDianHua + "</span>)" +
                            "</div>" +
                            "</div>" +
                            "</div>";

                    }
                    //$("#div_XiaoShouJiLuLine").html(left);
                    $("#div_XiaoShouJiLu").html(right);
                    //console.log(daofang);
                    //console.log(yigoumai);
                    if (daofang == true) {
                        $("#line_DaoFang").attr("class", "line actived");
                        $("#yuan_DaoFang").attr("class", "circle actived")
                    }
                    if (yigoumai == true) {
                        $("#line_GouMai").attr("class", "line actived");
                        $("#yuan_GouMai").attr("class", "circle actived")
                    }

                }
            });
        }


        function ShouJi(cellValue) {
            if (Number(cellValue) && String(cellValue).length === 11) {

                var mobile = String(cellValue)

                var reg = /^(\d{3})\d{4}(\d{4})$/

                return mobile.replace(reg, '$1****$2')

            } else {

                return cellValue

            }

        }

        function daofang() {
            $("#nb").removeAttr("hidden");
            $("#btn_QueRenDaoFang").attr("disabled", "disabled");
            var KeHuId = getQuery("KeHuId");
            $.ajax({
                type: "POST",
                url: "../PhoneKeHu/QueRenDaoFangSubmit",
                cache: false,  //禁用缓存
                data: { "KeHuId": "" + KeHuId + "", "CaoZuoLeiXing": "querendaofang" },  //传入组装的参数
                dataType: "text",
                success: function (result) {
                    $("#nb").attr("hidden", "");
                    $("#btn_QueRenDaoFang").attr("disabled", false);
                    if (result == "success") {
                        swal("成功提示!", "保存成功!", "success");
                        setTimeout(function () { window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww500458ad942a211f&redirect_uri=http://web.xyufu.cn/PhoneShouYe/ShouYe&response_type=code&scope=snsapi_privateinfo&agentid=1000002&state=STATE#wechat_redirect"; }, 2000);
                    }
                    else {
                        swal("失败提示!", "保存失败!", "error");
                    }
                }
            });
        }

        function weidaofang() {
            $("#nb").removeAttr("hidden");
            $("#btn_WeiDaoFang").attr("disabled", "disabled");
            var KeHuId = getQuery("KeHuId");
            $.ajax({
                type: "POST",
                url: "../PhoneKeHu/QueRenDaoFangSubmit",
                cache: false,  //禁用缓存
                data: { "KeHuId": "" + KeHuId + "", "CaoZuoLeiXing": "weidaofang" },  //传入组装的参数
                dataType: "text",
                success: function (result) {
                    $("#nb").attr("hidden", "");
                    $("#btn_WeiDaoFang").attr("disabled", "block");
                    if (result == "success") {
                        swal("成功提示!", "保存成功!", "success");
                        setTimeout(function () { window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww500458ad942a211f&redirect_uri=http://web.xyufu.cn/PhoneShouYe/ShouYe&response_type=code&scope=snsapi_privateinfo&agentid=1000002&state=STATE#wechat_redirect"; }, 2000);
                    }
                    else {
                        swal("失败提示!", "保存失败!", "error");
                    }
                }
            });
        }

        function PanDuanShiFouQueRenGuo(KeHuId) {
            $.ajax({
                type: "POST",
                url: "../PhoneKeHu/PanDuanShiFouQueRenGuo",
                cache: false,  //禁用缓存
                data: { "KeHuId": "" + KeHuId + "" },  //传入组装的参数
                dataType: "text",
                success: function (result) {
                    if (result == "back") {
                        swal("失败提示!", "该申请已确认!", "error");
                        setTimeout(function () { window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=ww500458ad942a211f&redirect_uri=http://web.xyufu.cn/PhoneShouYe/ShouYe&response_type=code&scope=snsapi_privateinfo&agentid=1000002&state=STATE#wechat_redirect"; }, 2000);
                    }
                    else {
                        $("#nb").attr("hidden", "");
                    }

                }
            });
        }

        function getQuery(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURI(r[2]); return null;
        }
    </script>
</head>


<body>
    <div class="header">
        <a href="My_Customer">
            <img src="~/GoTRI/img/myCustomer/icon.png">
        </a>
    </div>
    <!-- 客户信息简介 -->
    <div class="introduction">
        <div class="head">
            <div class="fl">
                <img src="~/GoTRI/img/男.jpg" id="img_TouXiangNan" style="display:none;">
                <img src="~/GoTRI/img/女.jpg" id="img_TouXiangNv" style="display:none;">
            </div>
            <div class="fr">
                <div class="cus-name">
                    <div><label id="lbl_KeHuXingMing"></label></div>
                    <div class="sign">
                        <span><label id="lbl_ZhuangTai"></label></span>
                    </div>
                </div>
                <div class="sign-time">
                    <span>推荐时间:</span>
                    <span>
                        <label id="lbl_TuiJianShiJian"></label>
                    </span>
                </div>
            </div>

        </div>
        @*<div class="contact">
            <div class="tele">
                <div class="tel-img">
                    <img src="~/GoTRI/img/myCustomer/details-tel.png">
                </div>
                <div><span><label id="lbl_ShouJiHaoMa"></label></span></div>
            </div>
            <div class="text">
                <div class="note-img"><img src="~/GoTRI/img/myCustomer/details-note.png"></div>
                <div><span>发送短信</span></div>
            </div>
        </div>*@

        <!-- 基本信息、客户轨迹 -->
        <div class="info-details">
            <ul class="nav nav-tabs">
                <li class="nav-item">
                    <a href="#baseinfo" class="nav-link active" data-toggle="tab">基本信息</a>
                </li>
                <li class="nav-item">
                    <a href="#custrack" class="nav-link" data-toggle="tab">客户轨迹</a>
                </li>

            </ul>
            <div class="tab-content">
                <!--基本信息 -->
                <div id="baseinfo" class="tab-pane active">
                    <div class="user-tel">
                        <span>手机号码<span class="red">*</span></span>
                        <input type="text" id="txt_ShouJiHaoMa">
                    </div>
                    <div class="user-name">
                        <span>客户姓名<span class="red">*</span></span>
                        <input type="text" id="txt_KeHuXingMing">
                    </div>
                    <div class="remarks">
                        <span>客户备注</span>
                        <span>
                            上次备注：
                            <span><label id="lbl_ShangCiGenJin"></label></span>
                        </span>
                    </div>
                    <textarea name="beihzu" id="txt_BeiZhu" cols="35" rows="3" placeholder="备注内容"></textarea>
                    <button class="btn btn-success" style="width:45%; margin-left:2.5%; float:left;" id="btn_QueRenDaoFang" onclick="daofang();">
                        <span>确认到访</span>
                        
                    </button>
                    <button class="btn btn-warning" style="width:45%; margin-left:2.5%;float:left;" id="btn_WeiDaoFang" onclick="weidaofang()">
                        <span>未到访</span>
                    </button>
                </div>
                <!-- 客户轨迹 -->
                <div id="custrack" class="tab-pane">
                    <div class="track-top">
                        <div>
                            <span>推荐成功</span>
                            <span>已到访</span>
                            <span>已成交</span>
                        </div>
                        <div>
                            <div>
                                <div class="circle actived">
                                    <div></div>
                                </div>
                            </div>
                            <div class="line" id="line_DaoFang"></div>
                            <div>
                                <div class="circle" id="yuan_DaoFang">
                                    <div></div>
                                </div>
                            </div>
                            <div class="line" id="line_GouMai"></div>
                            <div>
                                <div class="circle" id="yuan_GouMai">
                                    <div></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="track-body">
                        @*<div class="body-left" id="div_XiaoShouJiLuLine">

                            </div>*@
                        <div class="body-right" id="div_XiaoShouJiLu">


                        </div>
                    </div>
                </div>

            </div>
        </div>
        <!-- 电话插件 -->
        <div id="telephone">
            <div>
                <div class="tel"><label id="lbl_ShouJiHaoMa1"></label></div>
                <div class="mybtn">
                    <div class="cancel">取消</div>
                    <div><a id="a_DianHuaHaoMa"><span style="color:orange;">拨打</span></a></div>
                </div>
            </div>
        </div>
        <!-- 短信插件 -->
        <div id="note">
            <div>
                <div class="tel"><label id="lbl_ShouJiHaoMa2"></label></div>
                <div class="mybtn">
                    <div class="cancel">取消</div>
                    <div><a id="a_FaDuanXin"><span style="color:orange;">发短信</span></a></div>
                </div>
            </div>
        </div>
        <script>
            $(function () {
                //  点击取消，隐藏弹框
                $("#note .cancel").click(function () {
                    $("#note").css({ "display": "none" });
                });
                $("#telephone .cancel").click(function () {
                    $("#telephone").css({ "display": "none" });
                });
                // 点击按钮显示弹框
                // 拨打电话
                $(".tele").click(function () {
                    $("#telephone").css({ "display": "block" });
                });
                // 发送短信
                $(".text").click(function () {
                    $("#note").css({ "display": "block" });
                });
            })
        </script>
    </div>
</body>
</html>